<?php
/**
 * Created by PhpStorm.
 * User: changyifan
 * Date: 2018/1/4
 * Time: 下午2:07
 * 教学管理
 */

namespace Home\Controller;
use Think\Controller;

class ClassController extends MainController{
    /* <-------------     授课班级管理   -------------> */
    public function class_manage(){
        $user_info = session(C('USER_AUTH_INFO'));
        $this->assign('teachingmethod_info',$this->teachingmethod->getTeachingMethodInfoListByAll());
        $this->assign('tea_name',$user_info['tea_name']);
        $this->assign('tctype_info',$this->tctype->getTctypeInfoListByAll());
        $this->display();
    }
    public function class_ShowDatatables(){
        $tme_id = I('tme_id');
        $tc_status = I('tc_status');
        $result['aaData'] = $this->teachingclass->getTeachingClassInfoListWithTeahcerMethodName($tme_id,$tc_status);
        echo json_encode($result);
    }
    public function add_teachingclass(){
        $data = I();
        var_dump($data);
        $result = $this->event->add_data($this->teachingclass_dao,$data);
        echo json_encode($result);
    }

    /* <-------------       学生管理    -------------> */
    public function class_student_manage(){
        $tc_info = $this->teachingclass -> getTeachingClassInfoListByAll();
        $this->assign('role_id',session(C('USER_AUTH_ROLE')));
        $this->assign('tc_info',$tc_info);
        $this->display();
    }
    public function  class_student_manage_ShowDatatables(){
        $tc_id = I('tc_id');
        $stu_tc_info = $this->stu_tc -> getStuTcInfoListWithTcId($tc_id);
        if ($stu_tc_info) {
            $result['aaData'] = $stu_tc_info;
        } else {
            $result['aaData'] = array();
        }
        echo json_encode($result);
    }
    public function check_TcStudent(){
        $data = I('check_value');
        $result = $this->stu_tc_dao->check_student($data);
        echo json_encode($result);
    }
    /* <-------------       添加授课班学生    -------------> */
    public function add_class_student(){
        $tec_name = I('tec_name');
        $this->assign('tec_name',$tec_name);
        $this -> assign('college_info', $this->event->getCollegeList());
        $this -> assign('department_info', $this->event->getDepatmentList());
        $this -> assign('noun_info', $this->event->getProfessionList());
        $this -> assign('class_info',$this->event->getNaturalClassList());
        $this->display();
    }
    public function add_class_student_ShowDatatables(){
        $class_id = I('class_id');
        $stu_num = I('stu_num');
        $student_info = $this->student-> getStudentInfoByClassIdAndStuNum($class_id,$stu_num);
        $result['aaData'] = $student_info;
        echo json_encode($result);
    }
    /* <-------------        添加授课班     -------------> */
    public function add_class(){
        $tec_name = I('tec_name');
        $this->assign('tec_name',$tec_name);
        $this -> assign('college_info', $this->event->getCollegeList());
        $this -> assign('department_info', $this->event->getDepatmentList());
        $this -> assign('noun_info', $this->event->getProfessionList());
        $this->display();
    }
    public function add_class_ShowDatatables(){
        $noun_id = I('noun_id');
        $class_info = $this->naturalclass->getNaturalInfoList($noun_id);
        $result['aaData'] = $class_info;
        echo json_encode($result);
    }
    /* <-------------       审核授课班    -------------> */
    public function check_teaching_class(){
        $this->assign('course_info',$this->event->getCourseList());
        $this->assign('teachingmethod_info',$this->teachingmethod->getTeachingMethodInfoListByAll());
        $this->display();
    }
    public function check_teaching_class_ShowDatatables(){
        $tme_id = I('tme_id');
        $result['aaData'] = $this->teachingclass->getTeachingClassInfoListWithTeahcerMethodName($tme_id,2);
        echo json_encode($result);
    }
    /* <-------------       考勤管理    -------------> */
    public function class_attendance_manage(){
        $tc_info = $this->teachingclass -> getTeachingClassInfoListByAll();
        $nc_info = $this->naturalclass->getClassInfoListByAll();
//        var_dump($nc_info);
        $this->assign('tc_info',$tc_info);
        $this->assign('nc_info',$nc_info);
        $this->display();
    }
    public function class_attendance_manage_ShowDatatables(){
        $tc_id = I('tc_id');
        $nc_id = I('nc_id');
        $stu_tc_status = I('stu_tc_status');
        $info = $this->stu_tc -> getAttendanceStuTcInfoListWithTcId($tc_id,$nc_id,$stu_tc_status);
        $result['aaData'] = $info;
        echo json_encode($result);
    }
    /* <-------------       公告管理    -------------> */
    public function class_annoucement_manage(){
        $tc_info = $this->teachingclass -> getTeachingClassInfoListByAll();
        $this->assign('tc_info',$tc_info);
        $this->display();
    }
    public function class_annoucement_ShowDatatables(){
        $tc_id = I('tc_id');
        $info = $this->annoucement -> getAnnounceInfoListWithTcId($tc_id);
        if ($info) {
            $result['aaData'] = $info;
        } else {
            $result['aaData'] = array();
        }
        echo json_encode($result);
    }

}